package 继承.继承的应用场景;
//Pig类:{name,age,sex,eat(),snore()};
public class Pig {
    //私有变量
    private String name;
    private int age;
    private String sex;
    //构造方法
    public Pig(){}//无参构造方法
    public Pig(String name,int age,String sex){
        this.name=name;
        this.age=age;
        this.sex=sex;
    }//有参构造方法
    //公共方法
    public void eat(){
        System.out.println(name+"吃猪食");

    }
    public void snore(){
        System.out.println(name+"会打鼾");

    }

    //私有变量相应的“get/set”方法
    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }
}
